package com.cheer.dto;

import cn.hutool.core.util.StrUtil;
import com.cheer.exception.ServiceException;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * excel 导入到表中的 excel 实体类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AccountImportDTO {

    private static final Map<String, String> headerAlias = Maps.newHashMap();

    private String orgName;

    private String admin;

    private String phone;

    private String accountBackup;


    static {
        headerAlias.put("部门名称","orgName");
        headerAlias.put("负责人","admin");
        headerAlias.put("账号","phone");
        headerAlias.put("备用账号","accountBackup");
    }

    public static Map<String, String> getHeaderAlias(){

        return headerAlias;
    }

    /**
     * 为空检查
     */
    public void emptyCheck( Integer lineIndex ){

        if(StrUtil.isEmpty(orgName)){
            throw new ServiceException("第" +lineIndex+"行：" + "未获取到部门名称信息！");
        }

        if(StrUtil.isEmpty(admin)){
            throw new ServiceException("第" +lineIndex+"行：" + "未获取到负责人信息！");
        }

        if(StrUtil.isEmpty(admin)){
            throw new ServiceException("第" +lineIndex+"行：" + "未获取到账号信息！");
        }

        if(StrUtil.isEmpty(admin)){
            throw new ServiceException("第" +lineIndex+"行：" + "未获取到备用账号信息！");
        }

    }



}
